package com.augurit.gzcgwsp.wfex.common.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.augurit.wf.bi.service.IWfBusTemplateService;
import com.augurit.wf.common.dao.Jbpm4HistTaskDao;
import com.augurit.wf.common.entity.Jbpm4HistTask;

@Repository
public class Jbpm4HistTaskDaoEX{

	@Autowired
	private Jbpm4HistTaskDao jbpm4HistTaskDao;
	/**
	 * 通过procInstId和state=open,获取Jbpm4HistTask
	 * @param procInstId
	 * @return
	 */
	public Jbpm4HistTask getHistTasksByProcInstIdAndState(String procInstId){
		Jbpm4HistTask jbpm4HistTask = null;
		List<Jbpm4HistTask> list = null;
		String hql = "from Jbpm4HistTask ps where ps.procInstId=:procInstId and ps.state='open'";
		Query query = jbpm4HistTaskDao.getSession().createQuery(hql);
		query.setString("procInstId", procInstId);
		list = query.list();
		if(list.size()>0){
			jbpm4HistTask = list.get(0);
		}
		return jbpm4HistTask;
	}
}
